package cn.tedu.vue_master.controller;

import cn.tedu.vue_master.pojo.spu.vo.SpuListItemVO;
import cn.tedu.vue_master.restful.JsonResult;
import cn.tedu.vue_master.service.ISpuService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "spu管理")
@RequestMapping("/spu")
public class SpuController {

    @Autowired
    private ISpuService spuService;

    @ApiOperation("根据品牌id获取spu列表")
    @GetMapping("/listByBrandId/{brandId:[0-9]+}")
    @ApiOperationSupport(order = 400)
    public JsonResult<List<SpuListItemVO>> listByBrandId(@PathVariable Long brandId) {
        log.debug("开始处理【根据品牌id获取spu列表】的请求...");
        List<SpuListItemVO> list = spuService.listByBrandId(brandId);
        return JsonResult.ok(list);
    }
}
